home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MACD 5
/
MACD 5.bin
/
polski_aminet
/
miroslaw_siedlarz
/
bcc
/
examples
/
joytest
/
app.bc
next >
Wrap
Text File
|
1997-06-22
|
7KB
|
261 lines
#include <proto/dos.h>
#include <proto/lowlevel.h>
#include <intuition/imageclass.h>
#include "App.bh"
#include "EJG.h"
void myputch( void );
static const char *centr[] = {
"Port 1 (mouse)",
"Port 2 (game)",
NULL
};
cleardata Method App::App() :
MUIA_Application_Author, "Rafaî Mantiuk",
MUIA_Application_Base, "JOYTEST",
MUIA_Application_Title, "JoyTest",
MUIA_Application_Version, "$VER: JOYTEST 1.0 "__AMIGADATE__,
MUIA_Application_Copyright, "Copyright (c)1997, Rafaî Mantiuk",
MUIA_Application_Description, "Joystick test.",
SubWindow, win = WindowObject,
MUIA_Window_Title, "Joystick test v1.0",
MUIA_Window_ID, MAKE_ID('M', 'A', 'I', 'N'),
WindowContents, GroupObject,
MUIA_Background, MUII_WindowBack,
MUIA_Group_Horiz, TRUE,
Child, GroupObject,
Child, cycle = CycleObject,
MUIA_Cycle_Entries, centr,
MUIA_Cycle_Active, 1,
MUIA_CycleChain, TRUE,
MUIA_Background, MUII_TextBack,
End,
Child, inf = TextObject,
MUIA_Background, MUII_TextBack,
End,
Child, HVSpace,
Child, GroupObject,
MUIA_Group_Columns, 3,
Child, HVSpace,
Child, up = ImageObject,
MUIA_Image_Spec, "6:11",
MUIA_Frame, MUIV_Frame_InputList,
MUIA_Image_FontMatch, TRUE,
MUIA_Background, MUII_ButtonBack,
End,
Child, HVSpace,
Child, left = ImageObject,
MUIA_Image_Spec, "6:13",
MUIA_Frame, MUIV_Frame_InputList,
MUIA_Image_FontMatch, TRUE,
MUIA_Background, MUII_ButtonBack,
End,
Child, HGroup,
Child, trig = ImageObject,
MUIA_Image_Spec, "6:16",
MUIA_Frame, MUIV_Frame_InputList,
MUIA_Image_FontMatch, TRUE,
MUIA_Background, MUII_ButtonBack,
MUIA_ShortHelp, "First fire button",
End,
Child, strig = TextObject,
MUIA_Frame, MUIV_Frame_InputList,
MUIA_Background, MUII_ButtonBack,
MUIA_Text_Contents, "2nd",
MUIA_ShortHelp, "Second fire button",
End,
End,
Child, right = ImageObject,
MUIA_Image_Spec, "6:14",
MUIA_Frame, MUIV_Frame_InputList,
MUIA_Image_FontMatch, TRUE,
MUIA_Background, MUII_ButtonBack,
End,
Child, HVSpace,
Child, down = ImageObject,
MUIA_Image_Spec, "6:12",
MUIA_Frame, MUIV_Frame_InputList,
MUIA_Image_FontMatch, TRUE,
MUIA_Background, MUII_ButtonBack,
End,
Child, HVSpace,
End,
Child, HVSpace,
Child, dval = TextObject,
MUIA_Background, MUII_TextBack,
MUIA_Text_PreParse, "\33c",
MUIA_ShortHelp, "Value returned by\nlowlevel.library/ReadJoyPort()",
End,
End,
Child, BalanceObject,
End,
Child, GroupObject,
MUIA_Group_Columns, 2,
Child, lup = ImageObject,
MUIA_Image_Spec, "6:11",
MUIA_Frame, MUIV_Frame_InputList,
MUIA_Image_FontMatch, TRUE,
MUIA_Background, MUII_ButtonBack,
End,
Child, EJGup = EJGObject,
End,
Child, ldown = ImageObject,
MUIA_Image_Spec, "6:12",
MUIA_Frame, MUIV_Frame_InputList,
MUIA_Image_FontMatch, TRUE,
MUIA_Background, MUII_ButtonBack,
End,
Child, EJGdown = EJGObject,
End,
Child, lleft = ImageObject,
MUIA_Image_Spec, "6:13",
MUIA_Frame, MUIV_Frame_InputList,
MUIA_Image_FontMatch, TRUE,
MUIA_Background, MUII_ButtonBack,
End,
Child, EJGleft = EJGObject,
End,
Child, lright =ImageObject,
MUIA_Image_Spec, "6:14",
MUIA_Frame, MUIV_Frame_InputList,
MUIA_Image_FontMatch, TRUE,
MUIA_Background, MUII_ButtonBack,
End,
Child, EJGright = EJGObject,
End,
Child, ltrig = ImageObject,
MUIA_Image_Spec, "6:16",
MUIA_Frame, MUIV_Frame_InputList,
MUIA_Image_FontMatch, TRUE,
MUIA_Background, MUII_ButtonBack,
MUIA_ShortHelp, "First fire button",
End,
Child, EJGtrig = EJGObject,
End,
Child, lstrig = TextObject,
MUIA_Frame, MUIV_Frame_InputList,
MUIA_Background, MUII_ButtonBack,
MUIA_Text_Contents, "2nd",
MUIA_ShortHelp, "Second fire button",
End,
Child, EJGstrig = EJGObject,
End,
End,
End,
End
{
win->_Notify(
MUIA_Window_CloseRequest, TRUE,
obj, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit );
left->_Notify(
MUIA_Image_State, MUIV_EveryTime,
lleft, 3, MUIM_Set, MUIA_Image_State, MUIV_TriggerValue );
right->_Notify(
MUIA_Image_State, MUIV_EveryTime,
lright, 3, MUIM_Set, MUIA_Image_State, MUIV_TriggerValue );
up->_Notify(
MUIA_Image_State, MUIV_EveryTime,
lup, 3, MUIM_Set, MUIA_Image_State, MUIV_TriggerValue );
down->_Notify(
MUIA_Image_State, MUIV_EveryTime,
ldown, 3, MUIM_Set, MUIA_Image_State, MUIV_TriggerValue );
trig->_Notify(
MUIA_Image_State, MUIV_EveryTime,
ltrig, 3, MUIM_Set, MUIA_Image_State, MUIV_TriggerValue );
strig->_Notify(
MUIA_Selected, MUIV_EveryTime,
lstrig, 3, MUIM_Set, MUIA_Selected, MUIV_TriggerValue );
win->Open = TRUE;
}
Attribute Set App::State( long value )
{
ULONG v, x;
STRPTR cont;
v = value & JP_DIRECTION_MASK;
if( value != lastval ) {
RawDoFmt( "$%lx", (ULONG*)&value, myputch, txbuf );
dval->Contents = txbuf;
}
lastval = value;
switch( value & JP_TYPE_MASK ) {
case JP_TYPE_JOYSTK:
cont = "Joystick detected";
break;
case JP_TYPE_MOUSE:
cont = "Mouse detected";
break;
case JP_TYPE_GAMECTLR:
cont = "Game controller detected";
break;
default:
cont = "Unknown device";
}
if( lastcont != cont ) {
inf->Contents = cont;
}
lastcont = cont;
if( ( value & JP_TYPE_MASK ) == JP_TYPE_JOYSTK ) {
if( v & JPF_JOY_UP ) {
up->State = IDS_SELECTED;
EJGup->Anim( 1 );
}
else {
up->State = IDS_NORMAL;
EJGup->Anim( 0 );
}
if( v & JPF_JOY_DOWN ) {
down->State = IDS_SELECTED;
EJGdown->Anim( 1 );
}
else {
down->State = IDS_NORMAL;
EJGdown->Anim( 0 );
}
if( v & JPF_JOY_LEFT ) {
left->State = IDS_SELECTED;
EJGleft->Anim( 1 );
}
else {
left->State = IDS_NORMAL;
EJGleft->Anim( 0 );
}
if( v & JPF_JOY_RIGHT ) {
right->State = IDS_SELECTED;
EJGright->Anim( 1 );
}
else {
right->State = IDS_NORMAL;
EJGright->Anim( 0 );
}
x = value & JPF_BUTTON_RED ? 1 : 0;
trig->State = x ? IDS_SELECTED : IDS_NORMAL;
EJGtrig->Anim( x );
x = value & JPF_BUTTON_BLUE ? 1 : 0;
strig->_Selected = x;
EJGstrig->Anim( x );
}
}
Attribute Get App::Port( ULONG *store )
{
*store = cycle->Active;
}